using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

namespace SG3L_RAG.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class TestController : ControllerBase
    {
        /// <summary>
        /// 简单的测试端点，不需要认证
        /// </summary>
        [HttpGet]
        [AllowAnonymous]
        public IActionResult Get()
        {
            return Ok(new 
            { 
                message = "CORS测试成功", 
                timestamp = DateTime.Now,
                server = "SG3L RAG API"
            });
        }

        /// <summary>
        /// 测试POST请求
        /// </summary>
        [HttpPost]
        [AllowAnonymous]
        public IActionResult Post([FromBody] object data)
        {
            return Ok(new 
            { 
                message = "POST请求成功", 
                received = data,
                timestamp = DateTime.Now
            });
        }

        /// <summary>
        /// 测试OPTIONS请求（预检请求）
        /// </summary>
        [HttpOptions]
        [AllowAnonymous]
        public IActionResult Options()
        {
            return Ok();
        }
    }
}
